package com.kkang.betmachine.util;

import com.kkang.betmachine.entity.LanQiuMatche;
import com.kkang.betmachine.entity.Pass;
import com.kkang.betmachine.ryc.LanQiuRycNetUti;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 502 二串一 投注
 *
 * @author yongk_liu
 **/
public class LanQiuBet502 {

    private static String pre = "502@";

    public static void bet(Pass pass, List<String> codes, int num) {
        List<String> list = new ArrayList<>();
        for (int j = 1; j <= num; j++) {
            StringBuffer sb = new StringBuffer(pre);

            Collections.shuffle(codes);
            sb.append(codes.get(0));

            Collections.shuffle(codes);
            sb.append(codes.get(0));

            list.add(sb.toString());
        }

        for (String code : list) {
            String result = LanQiuRycNetUti.bet(pass, code, 200);
            if (result.indexOf(",\"errorCode\":\"0\",") > -1) {
//                System.out.println(code + " 投注成功：");
            } else {
                System.out.println(code + " 投注失败：" + result);
            }
            try {
                Thread.currentThread().sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println(" -------------------------投注完成-----------------------");
    }

}
